package studentcourse.entity;

//继承Person
public class Student extends Person {
    //所选课程封装为private
    private Course selectedCourse;

    //调用父类
    public Student(String id, String name, String gender) {
        super(id, name, gender);
    }

    //选课
    public void selectCourse(Course targetCourse) {
        this.selectedCourse = targetCourse;
        System.out.println(name + "（" + id + "）已选课程：" + targetCourse.getCourseName());
    }

    //退课
    public void dropCourse() {
        if (selectedCourse != null) {
            System.out.println(name + "（" + id + "）已退课程：" + selectedCourse.getCourseName());
            this.selectedCourse = null;
        } else {
            //我不想写备注，但我怕改的时候没法改了
            //我平手有两讨厌，1我讨厌写备注，2我讨厌不写备注的人
            //应该没人发现吧
            System.out.println(name + "（" + id + "）当前无课程可退");
        }
    }


    //打印
    @Override
    public void printWorksheet() {
        System.out.println("\n=== 学生课表（工作单）===");
        System.out.println("学生ID：" + this.id);
        System.out.println("学生姓名：" + this.name);
        System.out.println("学生性别：" + this.gender);// 访问父类protected属性
        if (selectedCourse != null) {
            System.out.println("所选课程ID：" + selectedCourse.getCourseId());
            System.out.println("所选课程名：" + selectedCourse.getCourseName());
            System.out.println("上课地点：" + selectedCourse.getCourseLocation());
            System.out.println("上课时间：" + selectedCourse.getCourseTime());
            System.out.println("授课教师ID：" + selectedCourse.getCourseTeacher());
        } else {
            System.out.println("当前未选任何课程");
        }
        System.out.println("======================");
    }

    //外部包访问所选课程
    public Course getSelectedCourse() {
        return selectedCourse;
    }
}